package com.huaxin.hxmoduleworkorder.mapping;

import com.huaxin.hxmoduleworkorder.common.enums.OrderType;
import com.huaxin.hxmoduleworkorder.dto.request.CustomerEvaluationCreateReqDTO;
import com.huaxin.hxmoduleworkorder.dto.request.CustomerEvaluationUpdateReqDTO;
import com.huaxin.hxmoduleworkorder.models.CustomerEvaluation;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

@Mapper(componentModel = "spring")
public interface CustomerEvaluationMapping {
    @Mapping(target = "orderType", ignore = true)
    CustomerEvaluation toEntity(CustomerEvaluationCreateReqDTO in);

    @AfterMapping
    default void afterMapping(CustomerEvaluationCreateReqDTO in, @MappingTarget CustomerEvaluation entity) {
        entity.setOrderType(OrderType.of(in.getOrderType()));
    }

    void updateEntity(CustomerEvaluationUpdateReqDTO in, @MappingTarget CustomerEvaluation entity);
}